package com.Ajava1704.for线程池2;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @类名: com.Ajava1704.for线程池2
 * @作者: lgt
 * @创建时间: 2020-02-11 19:58
 * @描述:创建一个单一的线程池
 **/
public class ForPoolTest2 {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newSingleThreadExecutor();  //创建一个单一的线程池

        for (int i = 0; i <5 ; i++) {
            final int h=i;
            Runnable runnable = new Runnable() {
                @Override
                public void run() {
                    for (int j = 0; j <5 ; j++) {
                        System.out.println(h+"**********"+j);
                    }
                }
            };
            executorService.submit(runnable);
        }
    }
}
